package com.ubb.damate.service.impl;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import com.ubb.damate.model.File;
import com.ubb.damate.service.FileServiceLocal;
import com.ubb.damate.service.FileServiceRemote;

/**
 * Session Bean implementation class FileService
 */
@Stateless
public class FileService implements FileServiceRemote, FileServiceLocal {

	@PersistenceContext(unitName = "damate-pu")
	private EntityManager em;

	@Override
	public File createOrUpdate(File file) {
		return em.merge(file);
	}

	@Override
	public void delete(File file) {
		 em.remove(em.merge(file));
	}

	@Override
	public File find(File file) {
		return em.find(com.ubb.damate.model.File.class, file);
	}

}
